@using TaskManager.Domain.BusinessObjects
@using TaskManager.Web.Extensions
@model TaskManager.Domain.BusinessObjects.Project
@{
    ViewBag.Title = "Project Details";
}
<asp:content id="Content1" contentplaceholderid="head" runat="server">
  <script src="@Url.Content("~/Scripts/ConfirmationDialog.js")" type="text/javascript"></script>
</asp:content>
@Html.ValidationSummaryEx(true)
<script type="text/jscript">
    $(function () {
        $('#delete').click(function () {
            ConfirmationDialog('confirmAction', "Project '@Model.Name' will be deleted permanently",
             'Task Manager', function () {
                 $('#deleteForm').submit();
             });
            return false;
        });
        $('#close').click(function () {
            ConfirmationDialog('confirmAction', "Would you like to close Project '@Model.Name'?",
             'Task Manager', function () {
                 $('#closeForm').submit();
             });
            return false;
        });
        $('#reopen').click(function () {
            ConfirmationDialog('confirmAction', "Would you like to reopen Project '@Model.Name'?",
             'Task Manager', function () {
                 $('#reopenForm').submit();
             });
            return false;
        });
    });
</script>
<div id="confirmAction" class="modal hide">
    <div class="modal-header">
        <a href="#" class="close">&times;</a>
        <h3>
            Task Manager</h3>
    </div>
    <div class="modal-body">
        <p>
            Text</p>
    </div>
    <div class="modal-footer">
        <input type="button" class="btn primary" id="confirmAction-btn1" value="OK">
        <input type="button" class="btn secondary" id="confirmAction-btn2" value="Cancel">
    </div>
</div>
<div class="well">
    <div class="row">
        <div class="span1" style="width: auto">
            @Html.ActionLink("Edit", "Edit", new { id = Model.Id, tab = ViewBag.Tab }, new { @class = "btn" })
        </div>
        @if (Model.State == ProjectState.InProgress)
        {
            <div class="span1" style="width: auto">
                @using (Html.BeginForm("Close", "Project", new { tab = ViewBag.Tab }, FormMethod.Post, new { id = "closeForm" }))
                {
                    @Html.Hidden("id", Model.Id)
                    <input type="submit" class="btn" value="Close" id="close" />
                }
            </div>
        }
        else
        {
            <div class="span1" style="width: auto">
                @using (Html.BeginForm("Reopen", "Project", new { tab = ViewBag.Tab }, FormMethod.Post, new { id = "reopenForm" }))
                {
                    @Html.Hidden("id", Model.Id)
                    <input type="submit" class="btn" value="Reopen" id="reopen" />
                }
            </div>
        }
        <div class="span1" style="width: auto">
            @using (Html.BeginForm("Delete", "Project", new { tab = ViewBag.Tab }, FormMethod.Post, new { id = "deleteForm" }))
            {
                @Html.Hidden("id", Model.Id)
                <input type="submit" class="btn" value="Delete" id="delete" />
            }
        </div>
    </div>
</div>

<div class="row" style="min-width:840px">
    <div class="span7">
        @using (Html.BeginForm())
        {
            <fieldset>
                @Html.NameAndValue("Name", @Model.Name)
                @Html.NameAndValue("Description", @Model.Description)
                @Html.NameAndValue("Tasks", (Model.Tasks == null ? "None" : Model.Tasks.Count.ToString()))
                @Html.NameAndValue("Created", @Model.Created.ToString())

                @if (@Model.State == ProjectState.Finished)
                {
                    @Html.NameAndValue("Closed", @Model.Updated.ToString())
                }
                else
                {
                    @Html.NameAndValue("Last Modified", @Model.Updated.ToString())
                }
            </fieldset>
        }
    </div>
    <div class="span7" style="float:right">
        <div id="logList" style="margin-top: 20px">
            @{Html.RenderAction("Log", new { id = @Model.Id, tab = ViewBag.Tab} );}
        </div>
    </div>
</div>